module.exports = function ($scope, $state, $stateParams,$resource,$modal, $modalInstance, toaster, items) {  
    $scope.sexarr = [{'label' : '男', 'value' : '0'}, {'label' : '女', 'value' : '1'}];
    // 准驾类型
    $scope.car_typearr = [{'label' : 'A1大挂哈哈', 'value' : '0'},{'label' : 'B几公交哈哈', 'value' : '1'}];
    $scope.vm = {
        'date' : '',
        'options' : {
            format: "YYYY-MM-DD",
            locale : 'zh-cn'
        }
    }
    $scope.info = {
        'photo_arr' : '',
        'mobile' : ''
    };
    if(items){
        $scope.info = items;
        $scope.array = items.photo_arr.split(",");
    }
    // 添加驾驶员
    $scope.save = function(){
        checkpnone($scope.info.mobile);
        $resource('/api/ac/dsc/trafficService/createDriverInfo', {}, {}).save($scope.info, function(res){
            console.log($scope.info);
            if(res.errcode !== 0){            
                toaster.error({title:"",body:res.errmsg});

            }else{
                toaster.warning({title:"",body:"操作成功"});
                $modalInstance.close();

                
            }
        });
    }






    $scope.image = function(){
        var para = $state.get('app.imageupload');
        //设置上传文件夹，以自己业务命名
        angular.extend(para, {
            resolve : {  
                'dir' : function(){
                    return 't1';
                }
            } 
        })
        console.log(para);
        var modalInstance = $modal.open(para);
        modalInstance.opened.then(function() {// 模态窗口打开之后执行的函数  
            console.log('modal is opened');  
        });  
        modalInstance.result.then(function(result) {  
            console.log(result);  
            $scope.imagearr = JSON.stringify(result);
            $scope.info.photo_arr = result.join(",");
            $scope.array = result;
            // console.log(result.split(","));
            // $scope.a.project_file=$scope.array;
            // $scope.a.project_file = array[0];
            // console.log(scope.info.img);
            // form.result['templete_lock_data_json'] = JSON.stringify(result.lock);
            // form.result['templete_check_data_json'] = result.unlock;

        }, function(reason) {  
            console.log(reason);// 点击空白区域，总会输出backdrop  
            // click，点击取消，则会暑促cancel  
            $log.info('Modal dismissed at: ' + new Date());  
        }); 
    };

    $scope.del=function(index){
        $scope.array.splice(index,1);
        $scope.a.project_file=$scope.array;
    }
	
            //正则判断电话号  

            function checkpnone(x) {
                console.log(x);
                if(!/^1[34578]\d{9}$/.test(x)) {
                    return "您输入的电话号长度或格式错误";
                    console.log('cuowe');
                }
            }

            // $scope.checkphone=function(x){
            //     if(!/^1[34578]\d{9}$/.test(x)) return "您输入的电话号长度或格式错误";
            // }

			// $scope.showphoneinfo=function(x){
            //     console.log(x);
            //     if(x==undefined){
            //         $scope.employee.phoneinfo="";
            //        return;
            //       }
            //     if(x==''){
            //         $scope.employee.phoneinfo="";
            //        return;
            //       }
                                         
            // if($scope.checkphone(x)=="您输入的电话号长度或格式错误"){                
            //     $scope.employee.phoneinfo="您输入的电话号长度或格式错误"
            // }else{
            //          $scope.employee.phoneinfo="";
            //         }
            // }


};
